package com.zatech.cgnci.project.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zatech.cgnci.project.base.utils.ConvertUtils;
import com.zatech.cgnci.project.entity.CgnciAccessoryDO;
import com.zatech.cgnci.project.mapper.CgnciAccessoryMapper;
import com.zatech.cgnci.project.service.CgnciAccessoryService;
import com.zatech.cgnci.project.vo.CgnciAccessoryVO;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import java.util.List;

/**
 * <p>
 * 附件 服务实现类
 * </p>
 *
 * @author Generator
 * @since 2024-12-17
 */
@Service
public class CgnciAccessoryServiceImpl extends ServiceImpl<CgnciAccessoryMapper, CgnciAccessoryDO> implements CgnciAccessoryService {

    @Override
    public void deleteByBizNoAndUploadNode(String bizNo, String uploadNode) {
        Assert.hasText(bizNo, "bizNo缺失!");
        Assert.hasText(uploadNode, "uploadNode缺失!");
        baseMapper.deleteByBizNoAndUploadNode(bizNo, uploadNode);
    }

    @Override
    public void insertList(List<CgnciAccessoryDO> accessoryList) {
        if (CollectionUtils.isEmpty(accessoryList)) {
            return;
        }
        accessoryList.forEach(e -> baseMapper.insert(e));
    }

    @Override
    public List<CgnciAccessoryVO> listAccessoryListByBusinessId(Long businessId) {
        List<CgnciAccessoryDO> accessoryList = this.list(new LambdaQueryWrapper<CgnciAccessoryDO>()
                .eq(CgnciAccessoryDO::getBusinessId, businessId));
        return ConvertUtils.convert(accessoryList, CgnciAccessoryVO.class);
    }
}
